package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.pojo.Permission;
import com.itheima.service.PermissionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Reference
    private PermissionService permissionService;

    @RequestMapping("/findAll")
    public Result findAll(){
        try {
            List<Permission> lists=permissionService.findAll();
            return new Result(true,"权限数据查询成功！",lists);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"权限数据查询失败！");
        }
    }
    @RequestMapping("/getPermissionByRoleId")
    public Result getPermissionByRoleId(Integer id){
        try {
            List<Integer> list = permissionService.getPermissionByRoleId(id);
            return new Result(true,"权限数据查询成功！",list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"权限数据查询失败！");
        }
    }
}
